package day5.day5_1;

import _超市.Member;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class SupermarketTest  {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
//反序列化
        Supermarket x=null;
        try {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\Users\\董\\Documents\\java笔记\\大王\\超市会员.TXT"));
            x=(Supermarket)ois.readObject();
            System.out.println(x.getDizhi()+" "+x.getName());
            System.out.println(Arrays.toString(x.list.toArray()));
            System.out.println(x.map.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        while (true){
            int a=in.nextInt();
            if (a==1){
                System.out.println("新会员开卡");
                System.out.print("新会员开卡");
                System.out.print("密码：");
                String k1=in.next();
                System.out.print("姓名：");
                String k2=in.next();
                System.out.print("手机号：");
                String k3=in.next();
                System.out.print("积分：");
                int k5=in.nextInt();
                x.kaika(new Member(k5,k1,k2,k3));
            }else if (a==2){
                System.out.println("查看");
                x.chakan();
            }else if (a==3){
                break;
            }
        }

        //序列化
        try {
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("C:\\Users\\董\\Documents\\java笔记\\大王\\超市会员.TXT"));

            objectOutputStream.writeObject(x);
            objectOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
